import type { FunctionOutputDtoSimple } from '@/api/authorization/admin/function/model';
import type { UserOutputDtoSimple } from '@/api/identity/admin/user/model';

import type { ErrorMessageMode, PageData } from '#/request';

import { request } from '@/utils/request/axios';

import { PageRequest } from '#/request';

/** 管理-用户功能枚举 */
export enum Api {
  /** 读取用户 */
  ReadUsers = '/api/admin/userFunction/readUsers',
  /** 读取用户功能 */
  ReadFunctions = '/api/admin/userFunction/readFunctions',
}

// #region 读取用户信息
/**
 * 读取用户信息
 * @param params 分页请求
 * @param mode 错误消息模型
 */
export function readUsers(params: PageRequest, mode: ErrorMessageMode = 'message') {
  return request.post<PageData<UserOutputDtoSimple>>(
    {
      url: Api.ReadUsers,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
// #endregion
// #region 读取用户功能信息
/**
 * 读取用户功能信息
 * @param userId 用户ID
 * @param params 分页请求
 * @param mode 错误消息模型
 */
export function readUserFunctions(userId: bigint | string, params: PageRequest, mode: ErrorMessageMode = 'message') {
  return request.post<PageData<FunctionOutputDtoSimple>>(
    {
      url: `${Api.ReadFunctions}?userId=${userId}`,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
// #endregion
